package com.example.a513;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Spinner;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;
import java.util.List;

import adpater.AnimationAdapter;
import entity.Animation;

public class BaseAdapterActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
    private Spinner spinner;
    private List<Animation>animations = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_base_adapter);

        spinner = findViewById(R.id.spinner_dialog);

        animations = Animation.getDefault();
        AnimationAdapter adapter = new AnimationAdapter(this, animations);
        spinner.setAdapter(adapter);
        //spinner.setSelection(0);
        spinner.setOnItemSelectedListener(this);
    }

    @Override

    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        Toast.makeText(BaseAdapterActivity.this,  animations.get(position).getTitle(),Toast.LENGTH_LONG);
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }
}